package sqlite

import (
	"gorm.io/driver/sqlite"
	"gorm.io/gorm"
)

const (
	DATASOURCENAME = "./bettle.db"
)

type SqliteDB struct {
	db *gorm.DB
}

func (s *SqliteDB) DB() *gorm.DB {
	return s.db
}

var (
	db *gorm.DB
)

func init() {
	var err error
	db, err = gorm.Open(sqlite.Open(DATASOURCENAME), &gorm.Config{})
	if err != nil {
		panic(err)
	}
}

// 获取数据库连接
func DB() *gorm.DB {
	return db
}
